import InteractiveBase from "../../../LevelCommon/InteractiveBase";
import ArrowLock from "./ArrowLock";
import Sound from "../../../../constant/SoundNameConstant";
import { utils } from "../../../../utils/CommonUtil";
import EnumData from "../../../../Enum/EnumData";

export default class ArrowLockKey extends InteractiveBase {
    /** 当前按键的方向*/
    public curDir: EnumData.ArrowDirEnum;
    /** 锁*/
    private arrowLock: ArrowLock;
    private curMaterial:Laya.BlinnPhongMaterial;
    private oringinColor:Laya.Vector4;
    private mowner: Laya.MeshSprite3D;
    onStart() {
        this.mowner = this.owner as Laya.MeshSprite3D;
        this.arrowLock = this.owner.parent.getComponent(ArrowLock);
        this.curMaterial = this.mowner.meshRenderer.material as Laya.BlinnPhongMaterial;
        this.oringinColor = this.curMaterial.albedoColor;
    }
    protected InteractiveLogic(): boolean {
        window.gameFacade.SoundMng.playSound(Sound.soundClipArr.BUTTON);
        this.arrowLock.InputDir(this.curDir);

        utils.CommonUtils.DOColorTween(this.curMaterial,new Laya.Vector4(1,0,0,1),100,new Laya.Handler(this,()=>{
            utils.CommonUtils.DOColorTween(this.curMaterial,this.oringinColor,100,null);
        }))
        return false;
    }
}